(function(){
    "use strict";
    app.controller('diskCtrl', ['$scope', 'httpLoad', '$rootScope','$modal','$state','$timeout','LANGUAGE',
        function($scope, httpLoad, $rootScope, $modal,$state, $timeout,LANGUAGE) {
            $rootScope.moduleTitle = '容器管理 > 硬盘卷';//定义当前页
            // $rootScope.link = '/statics/css/user.css';//引入页面样式
            $scope.param = {
                rows: 10
            };
            $scope.isbatchDelete = true;
            //获取主机列表
            $scope.getData = function(page){
                $scope.param.page = page || $scope.param.page;
                var params = {
                        page: $scope.param.page,
                        rows: $scope.param.rows,
                        name:$scope.searchByName
                    };
                httpLoad.loadData({
                    url:'/deployer/getAllVolumesInfo.do',
                    data: params,
                    success:function(data){
                        if(data.rows&&data.rows.length!=0){
                            $scope.diskList = data.rows;
                            $scope.totalCount = data.records;
                            $scope.isImageData = false;
                        }else{
                            $scope.isImageData = true;
                        }
                    }
                });
            };
            $scope.getData(1);

            //日志
            $scope.log = function(id){  //打开模态
                var modalInstance = $modal.open({
                    templateUrl : '/statics/tpl/containerManger/container/log.html',
                    controller : 'logModalCtrl',
                    resolve : {
                        id: function() {
                            return  id;
                        }
                    }
                });
                modalInstance.result.then(function(){
                },function(){});
            };
            //监控
            $scope.monitor = function(id){  //打开模态
                var modalInstance = $modal.open({
                    templateUrl : '/statics/tpl/containerManger/container/monitor.html',
                    controller : 'monitorModalCtrl',
                    resolve : {
                        id: function() {
                            return  id;
                        }
                    }
                });
                modalInstance.result.then(function(){
                },function(){});
            };
            //终端
            $scope.terminal = function(id){  //打开模态
                var modalInstance = $modal.open({
                    templateUrl : '/statics/tpl/containerManger/container/terminal.html',
                    controller : 'terminalModalCtrl',
                    resolve : {
                        id: function() {
                            return  id;
                        }
                    }
                });
                modalInstance.result.then(function(){
                },function(){});
            };
            $scope.goApp = function(item){  //打开模态
                $state.go('app.application.developDetail',{id:item.appId,appName:item.appName.substring(0,item.appName.indexOf("-")),appCoreRename:item.appName,flag:3});
            };
        }
    ]);
    //日志ctrl
    angular.module('app').controller('logModalCtrl',['$scope','$modalInstance','id','LANGUAGE','httpLoad',
        function($scope,$modalInstance,id,LANGUAGE,httpLoad){ //依赖于modalInstance
            httpLoad.loadData({
                url:'/container/log',
                method:'POST',
                data:{id: id},
                success:function(data){
                    if(data.success){
                        $scope.codeMirror.setValue(data.message);
                    }else{
                        $scope.pop(data.message);
                    }
                }
            });
            $scope.cancel = function(){
                $modalInstance.dismiss('cancel'); // 退出
            }
        }]);
    //监控ctrl
    angular.module('app').controller('monitorModalCtrl',['$scope','$modalInstance','id','LANGUAGE','httpLoad',
        function($scope,$modalInstance,id,LANGUAGE,httpLoad){ //依赖于modalInstance
            httpLoad.loadData({
                url:'/container/monitor',
                method:'POST',
                data:{id: id},
                success:function(data){
                    if(data.success){
                    }else{
                        $scope.pop(data.message);
                    }
                }
            });
            $scope.cancel = function(){
                $modalInstance.dismiss('cancel'); // 退出
            }
        }]);
    //终端ctrl
    angular.module('app').controller('terminalModalCtrl',['$scope','$modalInstance','id','LANGUAGE','httpLoad',
        function($scope,$modalInstance,id,LANGUAGE,httpLoad){ //依赖于modalInstance
            httpLoad.loadData({
                url:'/container/terminal',
                method:'POST',
                data:{id: id},
                success:function(data){
                    if(data.success){
                        $scope.codeMirror.setValue(data.message);
                    }else{
                        $scope.pop(data.message);
                    }
                }
            });
            $scope.cancel = function(){
                $modalInstance.dismiss('cancel'); // 退出
            }
        }]);
})();